package com.xxxtentacion.mr.exam.step2;

import com.xxxtentacion.mr.writablecomparable.SortDriver;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;
/**
 * @author urboifrdscks!
 */
public class ExamDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration configuration = new Configuration();
        Job job = Job.getInstance(configuration, "ExamDriver");
        // 针对reducer端输出压缩（snappy压缩）
//        configuration.set("mapreduce.output.fileoutputformat.compress","true");
//        configuration.set("mapreduce.output.fileoutputformat.compress.type","RECORD");
//        configuration.set("mapreduce.output.fileoutputformat.compress.codec","org.apache.hadoop.io.compress.SnappyCodec");

        job.setJarByClass(ExamDriver.class);
        job.setMapperClass(ExamMapper.class);
        job.setReducerClass(ExamReducer.class);
        job.setMapOutputKeyClass(ExamBean.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(ExamBean.class);
        FileInputFormat.setInputPaths(job, new Path("E:\\wctest\\exam\\input_step1"));
        FileOutputFormat.setOutputPath(job, new Path("E:\\wctest\\exam\\output_step222222222222"));
        boolean flag = job.waitForCompletion(true);
        System.exit(flag ? 0 : -1);
    }
}
